/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.openmrs.module.basicmodule.DSS.Interpreter;

import org.openmrs.module.basicmodule.DSS.ast.BlockTree;
import org.openmrs.module.basicmodule.DSS.ast.FormalsTree;
import org.openmrs.module.basicmodule.DSS.ast.AST;
import org.openmrs.module.basicmodule.DSS.ast.IdTree;
import org.openmrs.module.basicmodule.DSS.Interpreter.Function.Function;

/**
 *
 * @author Stephen
 */
public class FunctionDeclaration {
    
    private AST t;
    private InterpreterVisitor iv;
    
    public FunctionDeclaration(AST t, InterpreterVisitor iv) {
        this.t = t;
        this.iv = iv;
    }
    
    public Object execute() {
        IdTree id = (IdTree)t.getKid(1);
        String functionName = id.getSymbol().toString();
        FormalsTree formals = (FormalsTree)t.getKid(2);
        BlockTree block = (BlockTree)t.getKid(3);
        
        SymbolTable.Scope.addFunction(functionName, new Function(formals, block));
        return null;
    }
}
